# -*- coding:UTF-8 -*-
import abc
class Shape(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def draw(self):
        pass

class Rectangle(Shape):
    @classmethod
    def draw(self):
        print("--Rectangle--")

class Square(Shape):

    def draw(self):
        print("--Square--")

class Color(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def fill(self):
        pass

class Red(Color):
    def fill(self):
        print("-Red-")

class Green(Color):
    def fill(self):
        print("-Green-")

class AbstractFactory(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def getColor(self,color):
        pass

    @abc.abstractmethod
    def getShape(self,shape):
        pass

class ShapeFactory(AbstractFactory):

    def getShape(self,shapeType):
        if(shapeType == "Rectangle"):
            return Rectangle()
        elif(shapeType == "Square"):
            return  Square()
        else:
            raise TypeError("%s" %shapeType)

    def getColor(self,colorType):
        return  None

class ColorFactory(AbstractFactory):
    def getColor(self,color):
        if(color == "Red"):
            return  Red()
        elif(color == "Green"):
            return Green()
        else:
            raise TypeError("%s" %color)

    def getShape(self,shape):
        return None

class FactoryProducer():
    @staticmethod
    def getFactory(choice):
        if(choice == "SHAPE"):
            return ShapeFactory()
        elif(choice == "COLOR"):
            return ColorFactory()
        else:
            return "输入正确的值"

if __name__ == "__main__":
    shapeFactory  = FactoryProducer.getFactory("SHAPE")
    shape1 = shapeFactory.getShape("Square")
    shape1.draw()
